var _ = require("lodash");
// 创建唯一值的数组，这个数组包含所有给定数组都包含的元素，
// 使用SameValueZero进行相等性比较。（注：可以理解为给定数组的交集
let arr = [1, 2];
let arr2 = [4, 2];
let arr3 = [1, 2];

let a = _.intersection(arr, arr2, arr3);
console.log(a);

let brr = [
  { name: "tom", age: "18" },
  { name: "tom2", age: "28" },
  { name: "tom3", age: "38" },
];
let brr2 = [
  { name: "tom4", age: "48" },
  { name: "tom2", age: "28" },
  { name: "tom5", age: "58" },
];
let brr3 = [
  { name: "tom6", age: "68" },
  { name: "tom2", age: "28" },
  { name: "tom7", age: "78" },
];
// 对象型的数据无法判断,需要使用intersectionBy或者intersectionWith方法
// 推荐使用intersectionWith方法intersectionWith
let b = _.intersection(brr, brr2, brr3);
console.log(b);
